/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.openmrs.module.basicmodule.DSS.Interpreter.Function;
import org.openmrs.module.basicmodule.DSS.Interpreter.SymbolTable;
import org.openmrs.module.basicmodule.DSS.ast.IdTree;
import java.util.ArrayList;
/**
 *
 * @author David
 */
public class IsObjectFunction extends Function{

    @Override
    public Object execute(ArrayList args) {

        String var = ((IdTree)args.get(0)).getSymbol().toString();
        String type = SymbolTable.Scope.getVarType(var);

        if (type.equalsIgnoreCase("boolean")) {
            //System.out.println("false");
            return false;
        } else if (type.equalsIgnoreCase("date")) {
            //System.out.println("false");
            return false;
        } else if (type.equalsIgnoreCase("float")) {
            //System.out.println("false");
            return false;
        } else if (type.equalsIgnoreCase("int")) {
            //System.out.println("false");
            return false;
        } else if (type.equalsIgnoreCase("list")) {
            //System.out.println("false");
            return false;
        } else if (type.equalsIgnoreCase("string")) {
            System.out.println("false");
            return false;
        } else {
            //Its an object!
            System.out.println("true!");
            return true;
        }
    }
}
